package com.android.demos.module.fresco;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.aaron.android.framework.base.ui.actionbar.AppBarSwipeBackActivity;
import com.aaron.android.framework.base.widget.recycleview.RecyclerItemDecoration;
import com.android.demos.R;
import com.android.demos.module.fresco.adapter.FrescoRecyclerAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created on 16/8/18.
 *
 * @author aaron.huang
 * @version 1.0.0
 */
public class FrescoActivity extends AppBarSwipeBackActivity {
    @BindView(R.id.recycle_view_fresco)
    RecyclerView mRecycleViewFresco;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fresco);
        ButterKnife.bind(this);
        setTitle("Fresco图片请求");
        initViews();
    }

    private void initViews() {
        mRecycleViewFresco = (RecyclerView) findViewById(R.id.recycle_view_fresco);
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
        mRecycleViewFresco.setLayoutManager(layoutManager);
        mRecycleViewFresco.addItemDecoration(new RecyclerItemDecoration(this,
                LinearLayoutManager.VERTICAL, R.drawable.main_recycler_divider));
        FrescoRecyclerAdapter frescoRecyclerAdapter = new FrescoRecyclerAdapter(this);
        List<String> list = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            list.add("http://desk.fd.zol-img.com.cn/t_s960x600c5/g5/M00/02/06/ChMkJ1bKyqKIPFxLAGZe49gDZ3YAALIegJkT54AZl77897.jpg"); //加载网络图片资源地址
        }
        list.add("http://img1.gamersky.com/image2014/06/20140608lk_4/2.gif"); //加载网络gif动图地址
        frescoRecyclerAdapter.setData(list);
        mRecycleViewFresco.setAdapter(frescoRecyclerAdapter);
    }
}
